﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using Xunit;

namespace UniSender.Test
{
    public class TestUtilityFunctions
    {
        CultureInfo culture = new CultureInfo("en-GB");

        [Fact]
        public void TestTimeStringify()
        {
            Assert.Equal("2014-07-15 13:25:08", Utility.Stringify(new DateTime(2014, 7, 15, 13, 25, 8, DateTimeKind.Utc)));
        }

        [Fact]
        public void TestTimeParsing()
        {
            var actual = Utility.ParseTime("2014-07-15 13:25:08").ToUniversalTime();
            Assert.Equal(2014, actual.Year);
            Assert.Equal(7, actual.Month);
            Assert.Equal(15, actual.Day);
            Assert.Equal(13, actual.Hour);
            Assert.Equal(25, actual.Minute);
            Assert.Equal(8, actual.Second);

            //actual = Utility.ParseTime("2014-06-25").ToUniversalTime();
            //Assert.Equal(2014, actual.Year);
            //Assert.Equal(6, actual.Month);
            //Assert.Equal(25, actual.Day);
        }

        [Fact]
        public void TestEnumStringify()
        {
            ContactStatus? actual = null;
            Assert.Null(actual.Stringify());
            
            actual = ContactStatus.ActivationRequested;
            Assert.Equal("activation_requested", actual.Value.Stringify());
            Assert.Equal("activation_requested", actual.Stringify());

            Assert.Equal("RUB", Currency.RUB.Stringify());
        }

        [Fact]
        public void TestEnumParse()
        {
            string actual = null;
            ContactStatus? expected = null;
            Assert.Equal(expected, Utility.ParseEnum<ContactStatus?>(actual));
            
            Assert.Equal(ContactStatus.ActivationRequested, Utility.ParseEnum<ContactStatus>("activation_requested"));

            Assert.Equal(Currency.RUB, Utility.ParseEnum<Currency>("RUB"));
        }
    }
}
